﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace BiessesXmlReader
{
    public class Material
    {
        public string id { get; private set; }
        public double Thickness { get; private set; }
        public string Grain { get; private set; }
        public string Density { get; private set; }
        public string Cost { get; private set; }
        public string Code { get; private set; }
        public static Material GetMaterial(XElement x)
        {
            Material M = new Material();
            XElement xm = x.Element("Material");
            M.id = (xm.Attribute("id") == null) ? string.Empty : xm.Attribute("id").Value;
            M.Thickness = (xm.Attribute("Thickness") == null) ? 0 : double.Parse(xm.Attribute("Thickness").Value);
            M.Grain = (xm.Attribute("Grain") == null) ? string.Empty : xm.Attribute("Grain").Value;
            M.Density = (xm.Attribute("Density") == null) ? string.Empty : xm.Attribute("Density").Value;
            M.Cost = (xm.Attribute("Cost") == null) ? string.Empty : xm.Attribute("Cost").Value;
            M.Code = (xm.Attribute("Code") == null) ? string.Empty : xm.Attribute("Code").Value;
            return M;
        }
    }
}
